<template>
    <div class="main-con distributionMember">
        <!-- 搜索框 -->
        <div class="search-con">
            <div class="search-item">
                <div class="search-item-title">分销员</div>
                <div class="search-item-input">
                    <el-input size="mini" v-model="formData.name" placeholder="请输入分销员"></el-input>
                </div>
            </div>
            <div class="search-item">
                <div class="search-item-title">手机号</div>
                <div class="search-item-input">
                    <el-input size="mini" v-model="formData.mobile" placeholder="请输入手机号"></el-input>
                </div>
            </div>
            <div class="search-item">
                <div class="search-item-title">加入时间</div>
                <div class="search-item-input">
                    <el-date-picker size="mini" :editable="false" class="w200" v-model="formData.beginTime" type="datetime"
                        placeholder="请选择开始时间" value-format="yyyy-MM-dd HH:mm:ss" :clearable="false"></el-date-picker>
                </div>
                <div>~</div>
                <div class="search-item-input">
                    <el-date-picker size="mini" :editable="false" class="w200" v-model="formData.endTime" type="datetime"
                        placeholder="请选择结束时间" value-format="yyyy-MM-dd HH:mm:ss" :clearable="false"></el-date-picker>
                </div>
            </div>
            <div class="search-item">
                <div class="search-item-title"></div>
                <el-button size="mini" type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
                <el-button size="mini" type="primary" icon="el-icon-delete" @click="handleClear">清空</el-button>
            </div>
        </div>

        <!-- 按钮组 -->
        <div class="btn-group-con">
            <el-button size="mini" type="primary" @click="handleExport">导出</el-button>
        </div>

        <!-- 表格数据 -->
        <div class="table-con" v-loading="loading">
            <el-table :data="tableData" size="mini" :header-cell-style="{background:'#f8f8f8'}" style="width: 100%">
                <el-table-column type="index" label="序号" width="50" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="name" label="分销员" width="" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="phone" label="手机号" width="" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="identityCode" label="标识码" width="" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="orderNum" label="累计成交笔数" width="" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="money" label="累计成交金额" width="" align="center" :show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="createTime" label="加入时间" width="" align="center" :show-overflow-tooltip="true">
                </el-table-column>
            </el-table>
        </div>

        <!-- 表格分页 -->
        <div class="pagination-con">
            <m-pagination :currentPage="formData.pageNum" :pageSize="formData.pageSize" :total="total"
                @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange">
            </m-pagination>
        </div>
    </div>
</template>

<script>
import { queryDistributionMemberInfo } from "@/common/service/distributionManagement/distributionMember.js";
import mPagination from "@/components/m-pagination/m-pagination";
import { api } from "@/common/http/index.js";
export default {
    name: "distributionMember",
    data() {
        return {
            // 搜索条件
            formData: {
                name: "", //区域名称
                mobile: "", //手机号
                beginTime: "", //开始时间
                endTime: "", //结束时间
                pageNum: 1,
                pageSize: 10
            },

            //表格数据
            tableData: [], //表格信息
            total: null, //表格总条数
            loading: false //表格加载动画
        };
    },
    created() {
        //初始化表格数据
        this._queryDistributionMemberInfo();
    },
    methods: {
        /*----------------------------查询操作----------------------------*/
        //查询地区门店表格数据
        _queryDistributionMemberInfo() {
            this.loading = true;
            queryDistributionMemberInfo(this.formData)
                .then(res => {
                    this.loading = false;
                    this.tableData = res.content;
                    this.total = res.totalElements;
                })
                .catch(err => {
                    this.loading = false;
                    this.$message.error(err.message);
                });
        },
        //页码切换
        handleCurrentChange(val) {
            this.formData.pageNum = val;
            this._queryDistributionMemberInfo();
        },
        //每页展示条数的切换
        handleSizeChange(val) {
            this.formData.pageSize = val;
            this._queryDistributionMemberInfo();
        },
        //点击查询
        handleSearch() {
            this.formData.pageNum = 1;
            this.formData.pageSize = 10;
            this._queryDistributionMemberInfo();
        },
        //点击清空
        handleClear() {
            this.formData = {
                name: "",
                mobile: "",
                beginTime: "",
                endTime: "",
                pageNum: 1,
                pageSize: 10
            };
            this.$message({
                type: "success",
                message: "清空成功!"
            });
            this._queryDistributionMemberInfo();
        },

        /*----------------------------导出操作----------------------------*/
        handleExport() {
            this.UTILS.exportUtil(
                api.exportDistributionMemberInfo,
                this.formData
            );
        }
    },
    components: {
        "m-pagination": mPagination
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>